package com.lyj.ui.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.lyj.dao.OptionDao;
import com.lyj.dao.impl.OptionDaoImpl;
import com.lyj.pojo.Option;
import com.lyj.pojo.Subject;
import com.lyj.service.SubjectService;
import com.lyj.service.impl.SubjectServiceImpl;
import com.lyj.util.RuleException;

/**
 * Servlet implementation class DoVoteServlet
 */
@WebServlet({"/JoinVoteServlet","/m/joinVote"})
public class JoinVoteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取subjectId
		String subjectId = request.getParameter("sid");
		int sid = Integer.parseInt(subjectId);
		//通过sid获取subject对象
		SubjectService subjectService = new SubjectServiceImpl();
		try {
			Subject subject = subjectService.getSubject(sid);
			request.setAttribute("subject", subject);
			request.getRequestDispatcher("/WEB-INF/pages/vote.jsp").forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
